/// @tags:
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

typedef long long ll;

constexpr int maxn = 5e5 + 2, maxk = 5e5 + 2;

int k;
int a[maxn], l[maxk], r[maxk], x[maxk];

bool check(int mid, ll s) {
  ll sum = 0;
  for (int i = 1; i <= k; ++i) {
    if (l[i] <= mid) sum += (ll)(std::min(mid, r[i]) - l[i] + 1) * x[i];
  }
  return sum >= s;
}

int find(ll sum, int n) {
  int L = 1, R = n, ans = 0;
  while (L <= R) {
    int mid = (L + R) / 2;
    if (check(mid, sum)) {
      ans = mid, R = mid - 1;
    } else {
      L = mid + 1;
    }
  }
  return ans;
}

int main() {
  int n, q;
  cin >> n >> q;
  cout << std::setprecision(12);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  while (q--) {
    cin >> k;
    ll sum = 0;
    for (int i = 1; i <= k; ++i) {
      cin >> l[i] >> r[i] >> x[i];
      sum += (ll)(r[i] - l[i] + 1) * x[i];
    }
    if (sum & 1) {
      cout << a[find(sum / 2 + 1, n)] << '\n';
    } else {
      cout << (a[find(sum / 2, n)] + a[find(sum / 2 + 1, n)]) / 2.0 << '\n';
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("J. Candies median.in", "r", stdin);
  freopen("J. Candies median.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
